import { sys } from 'cc';
import BaseData from './BaseData';
import { StorageName } from './StorageName';
import { EventName } from './EventName';
import { IniData } from './IniData';
import SdkFactory from './SdkFactory';
import OnFire from './OnFire';

export default class GameControl {
    // 单例模式
    private static _instance: GameControl = null;
    public static getInstance() {
        if (this._instance == null) {
            this._instance = new GameControl();
        }
        return this._instance;
    }

    private _baseData: BaseData = null;
    constructor() {
        this._baseData = new BaseData();
    }

    // 登录统一入口
    Login() {
        SdkFactory.getInstance().SdkAPI.login().then(res => {
            printLog('后端数据返回', res);
            if (res.status) {
                this._baseData.init(res.data);
            } else {
                let _res = { "status": false, "data": null };
                if (this.getLocalStorage(StorageName.GAME_DATA)) {
                    _res = { "status": true, "data": this.getLocalStorage(StorageName.GAME_DATA) };
                }
                this._baseData.init(_res.data);
            }
        })

    }

    // 获取本地存储
    getLocalStorage(key) {
        // if (cc.sys.platform == cc.sys.WECHAT_GAME) {
        //     return SdkFactory.getInstance().SdkAPI.hasOwnProperty(key) ? SdkFactory.getInstance().SdkAPI.getStorage(key) : false;
        // } else {
        //     return cc.sys.localStorage.hasOwnProperty(key) && cc.sys.localStorage.getItem(key) !== 'undefined' ? JSON.parse(cc.sys.localStorage.getItem(key)) : false;
        // }

        if (sys.platform == sys.WECHAT_GAME) {
            // printLog('Storage01', SdkFactory.getInstance().SdkAPI.getStorage(key));
            return SdkFactory.getInstance().SdkAPI.getStorage(key) == "" ? false : SdkFactory.getInstance().SdkAPI.getStorage(key);
        } else {
            // printLog('Storage02', cc.sys.localStorage.getItem(key));
            return sys.localStorage.getItem(key) != "" ? JSON.parse(sys.localStorage.getItem(key)) : false;
        }

        // if (cc.sys.platform !== 101 || cc.sys.platform !== cc.sys.MEIZU_GAME) {
        //     return SdkFactory.getInstance().SdkAPI.getStorage(key) == "" ? false : SdkFactory.getInstance().SdkAPI.getStorage(key);
        // } else {
        //     return cc.sys.localStorage.getItem(key) != "" ? JSON.parse(cc.sys.localStorage.getItem(key)) : false;
        // }
    }
    setLocalStorage(data) {
        if (sys.platform == sys.WECHAT_GAME) {
            SdkFactory.getInstance().SdkAPI.setStorage(data.key, data.value);
        } else {
            sys.localStorage.setItem(data.key, JSON.stringify(data.value));
        }
    }

    // 金币
    getGold() {
        if (this._baseData.gold <= 0 || isNaN(this._baseData.gold)) {
            this._baseData.gold = 0;
        }
        return Math.round(this._baseData.gold);
    }
    setGold(number: number) {
        this._baseData.gold += number;
        this._baseData.saveStorage();
    }

    // 钻石
    getDiamonds() {
        if (this._baseData.diamonds <= 0 || isNaN(this._baseData.diamonds)) {
            this._baseData.diamonds = 0;
        }
        return Math.round(this._baseData.diamonds);
    }
    setDiamonds(number: number) {
        this._baseData.diamonds += number;
        this._baseData.saveStorage();
    }

    // 体力
    getPower() {
        if (this._baseData.power <= 0 || isNaN(this._baseData.power)) {
            this._baseData.power = 0;
        }
        return Math.round(this._baseData.power);
    }
    setPower(number: number) {
        this._baseData.power += number;
        this._baseData.saveStorage();
    }

    // 关卡
    getPassId() {
        return this._baseData.passID;
    }
    setPassId(id: number) {
        let obj = this.getGameConfig('pass');
        let arr = Object.keys(obj);
        let max = arr.length;

        if (id >= max) {
            id = max;
        }

        this._baseData.passID = id;
        this._baseData.saveStorage();
    }

    // 当前使用的拍子
    getBatId() {
        return this._baseData.batId;
    }
    setBatId(id: number) {
        this._baseData.batId = id;
        this._baseData.saveStorage();
    }
    getBackupBatId() {
        return this._baseData.backupBatId;
    }
    setBackupBatId(id) {
        this._baseData.backupBatId = id;
        this._baseData.saveStorage();
    }

    // 经验值
    getXP() {
        return this._baseData.XP;
    }
    setXP(xp: number) {
        this._baseData.XP += xp;
        this._baseData.saveStorage();
    }

    // 配置表
    getGameConfig(key?: any) {
        if (key) {
            return this._baseData.GameConfig[key];
        } else {
            return this._baseData.GameConfig;
        }
    }
    setGameConfig(data: any) {
        this._baseData.GameConfig = data;
    }

    // 头衔
    getTitle() {
        let obj = this.getGameConfig("title");
        let a = obj["11"];
        Object.keys(obj).forEach((key) => {
            let min = obj[key].min;
            let max = obj[key].max;
            let xp = this.getXP();
            if (xp >= min && xp <= max) {
                a = obj[key];
            }
        });
        return a;
    }

    // 更换当前手机的品牌
    getPhoneSystem() {
        return this._baseData.phoneSystem;
    }
    setPhoneSystem(value) {
        // let s = value.split(" ")[0];
        this._baseData.phoneSystem = value;
    }

    // 获取小游戏的app_id
    getAppID() {
        // return this._baseData.AppID;
        return IniData.APPID;
    }

    // 获取用户openID
    getOpenID() {
        return this._baseData.openID;
    }
    setOpenId(id) {
        this._baseData.openID = id;
    }

    // 获取分享图信息
    getShareImgList() {
        //
        return this._baseData.shareImgList;
    }
    setShareImgList(data) {
        this._baseData.shareImgList = data;
    }

    // 获取诱导开关信息
    getShareSwitch() {
        // 正式使用
        if (this._baseData.shareSwitchList.hasOwnProperty(IniData.GAMEVERSION) &&
            this._baseData.shareSwitchList[IniData.GAMEVERSION] == 1) {
            return true;
        } else {
            return false;
        }
    }
    setShareSwitch(data) {
        this._baseData.shareSwitchList = data;
    }

    // 更新广告导出Icon资源
    getADIconDataList(id) {
        let data = []
        for (let index = 0; index < this._baseData.ADIconDataList.length; index++) {
            if (this._baseData.ADIconDataList[index].game_id == id) {
                data.push(this._baseData.ADIconDataList[index])
            }
        }
        return data
    }
    setADIconDataList(data) {
        this._baseData.ADIconDataList = data
    }

    // 通过game_id来查找游戏信息
    getWXGameInfo(gameInfo) {
        let info = null
        let arr = gameInfo.split('_')
        let icon_code = arr[0]
        let game_app_id = arr[1]
        for (let index = 0; index < this._baseData.ADIconDataList.length; index++) {
            if (this._baseData.ADIconDataList[index].game_app_id == game_app_id && this._baseData.ADIconDataList[index].icon_code == icon_code) {
                info = this._baseData.ADIconDataList[index]
                break
            }
        }
        return info
    }

    // 获取所有碎片拍子数据
    getChipBatInfo(id?: number) {
        // 如果没有数据，直接返回false！
        if (Object.keys(this._baseData.chipBatInfo).length === 0) return false;
        if (id) {
            return this._baseData.chipBatInfo[id];
        }
        return this._baseData.chipBatInfo;
    }
    setChipBatInfo() {
        const obj = this.getGameConfig('bat');
        let data = {};
        Object.keys(obj).forEach((key) => {
            if (obj[key].id > 100) {
                data[obj[key].id] = obj[key];
            }
        });
        this._baseData.chipBatInfo = data;
    }

    // 获取可用使用的碎片拍子
    getChipBatList() {
        if (this._baseData.chipBatList.length > 1) {
            if (this._baseData.chipBatList.indexOf(0) !== -1) {
                this._baseData.chipBatList.splice(this._baseData.chipBatList.indexOf(0), 1);
                this._baseData.saveStorage();
            }
        }

        if (this._baseData.chipBatList[0] == 0) {
            let a = [];
            return a;
        }
        return this._baseData.chipBatList;
    }
    setChipBatList(id) {
        if (this._baseData.chipBatList.indexOf(id) == -1) {
            this._baseData.chipBatList.push(id);
            this._baseData.saveStorage();
        }
    }

    // 获取收集的碎片信息
    getBatChipCount() {
        return this._baseData.batChipCount;
    }
    setBatChipCount(type) {
        switch (type) {
            case 0:
                this._baseData.batChipCount = 0;
                break;
            case 1:
                this._baseData.batChipCount += this._baseData.passBatChipCount;
                break;
            case 2:
                this._baseData.batChipCount <= 0 ? this._baseData.batChipCount = 0 : this._baseData.batChipCount -= this._baseData.passBatChipCount;
                break;
        }
        this._baseData.saveStorage();
    }

    // 当前关卡收集到的碎片
    getPassBatChipCount() {
        return this._baseData.passBatChipCount;
    }
    setPassBatChipCount(type) {
        if (type == -1) {
            this._baseData.passBatChipCount <= 0 ? this._baseData.passBatChipCount = 0 : this._baseData.passBatChipCount -= 1;
            return;
        } else if (type == 0) {
            this._baseData.passBatChipCount = 0;
            return;
        } else {
            this._baseData.passBatChipCount += type;
            return;
        }
    }

    // 获取碎片掉落的概率
    getChipBatChance() {
        // 获取碎片的基础概率
        const a = this.getChipBatInfo(this._baseData.chipBatId).chance;
        return a + this._baseData.addChance;
    }
    setAddChance(number: number) {
        this._baseData.addChance += number;
        this._baseData.saveStorage();
    }

    // 获取当前需要收集碎片的拍子
    getChipBatId() {
        return this._baseData.chipBatId;
    }
    setChipBatId(id: number) {
        if (id > 104) id = 104;
        this._baseData.chipBatId = id;
        this._baseData.saveStorage();
    }

    // 任务
    // Constants.GameControl.getTask(1) 或者 Constants.GameControl.getTask()
    getTask(id?: any) {
        if (id == 0) return this._baseData.taskData[id][0];
        if (id) {
            return this._baseData.taskData[id - 1][0];
        } else {
            return this._baseData.taskData;
        }
    }
    // Constants.GameControl.setTask(1): 完成未领取或者未完成状态

    // 注意：完成并领取状态必须要带一个状态值1
    // Constants.GameControl.setTask(1, 1)：完成并领取状态
    // 0：完成未领取，1：完成并领取，2：未完成
    setTask(id, state?: any) {
        // id不能等于0，或者状态为1（完成并领取）
        if (id == 0 || this._baseData.taskData[id - 1][0].state == 1) return;
        if (state == 1) {
            this._baseData.taskData[id - 1][0].state = 1;
            let index = this._baseData.taskList.indexOf(id);
            this._baseData.taskList.splice(index, 1);
            this._baseData.saveStorage();
            return;
        }

        const _task = this.getTask(id);
        const _total = _task.targetNum;
        let _count = _task.nowNum;
        _count += 1;

        if (_count >= _total && this._baseData.taskData[id - 1][0].state != 0) {
            // 完成未领取
            OnFire.getInstance().emit(EventName.GAME_TASK_STATUS, { key: true });
            this.setTaskList(id);
            this._baseData.taskData[id - 1][0].nowNum = _total;
            this._baseData.taskData[id - 1][0].state = 0;
        } else {
            // 未完成
            this._baseData.taskData[id - 1][0].nowNum = _count;
        }
        this._baseData.saveStorage();
    }
    updataTask(data) {
        this._baseData.taskData = [];
        Object.keys(data).forEach((key) => {
            let a = [];
            if (data[key].id == 2) {
                data[key].batId = this.getChipBatId();
            }

            if (data[key].id == 3) {
                let n = this.getMaxBatLV();
                n += 3;
                data[key].taskName = '提升武器' + n + '级';
                data[key].targetNum = n;
            }

            if (data[key].id == 4) {
                let m = this.getMaxBatLV();
                m += 1;
                data[key].taskName = '商场解锁' + m + '级武器';
                data[key].targetNum = m;
            }

            a.push(data[key]);
            this._baseData.taskData.push(a);
        });
        this._baseData.saveStorage();
    }

    // 获取完成的任务列表
    getTaskList() {
        return this._baseData.taskList;
    }
    setTaskList(id) {
        this._baseData.taskList.push(id);
    }

    // 获取拍子最高等级
    getMaxBatLV() {
        return this._baseData.maxBatLV;
    }
    setMaxBatLV(number) {
        this._baseData.maxBatLV = number;
        this._baseData.saveStorage();
    }

    // 获取用户信息
    getUserData() {
        return this._baseData.userData;
    }
    setUserData(data) {
        this._baseData.userData = data;
    }

    // 大招的数量
    getBigSkill() {
        return this._baseData.bigSkillCount;
    }
    // Constants.GameControl.setBigSkill(0)
    setBigSkill(type) {
        if (type == 0) {
            this._baseData.bigSkillCount = 0;
        } else if (type == -1) {
            this._baseData.bigSkillCount <= 0 ? this._baseData.bigSkillCount = 0 : this._baseData.bigSkillCount -= 1;
        } else {
            this._baseData.bigSkillCount += type;
        }
        this._baseData.saveStorage();
    }
    // 磁铁的数量
    getMagnetSkill() {
        return this._baseData.magnetSkillCount;
    }
    // Constants.GameControl.setMagnetSkill(0)
    setMagnetSkill(type) {
        if (type == 0) {
            this._baseData.magnetSkillCount = 0;
        } else if (type == -1) {
            this._baseData.magnetSkillCount <= 0 ? this._baseData.magnetSkillCount = 0 : this._baseData.magnetSkillCount -= 1;
        } else {
            this._baseData.magnetSkillCount += type;
        }
        this._baseData.saveStorage();
    }
    // 速度的数量
    getSpeedSkill() {
        return this._baseData.speedSkillCount;
    }
    // Constants.GameControl.setSpeedSkill(0)
    setSpeedSkill(type) {
        if (type == 0) {
            this._baseData.speedSkillCount = 0;
        } else if (type == -1) {
            this._baseData.speedSkillCount <= 0 ? this._baseData.speedSkillCount = 0 : this._baseData.speedSkillCount -= 1;
        } else {
            this._baseData.speedSkillCount += type;
        }
        this._baseData.saveStorage();
    }

    // 抽奖次数
    getLottery() {
        return this._baseData.lottery;
    }
    setLottery(count) {
        this._baseData.lottery += count;
        this._baseData.saveStorage();
    }

    // VIP看视频的次数
    getVipVideo() {
        return this._baseData.vipVideo;
    }
    setVipVideo() {
        this._baseData.vipVideo += 1;
        this._baseData.saveStorage();
    }

    // 抽奖看视频的次数
    getLotteryVideo() {
        return this._baseData.lotteryVideo;
    }
    setLotteryVideo(type) {
        switch (type) {
            case 0:
                this._baseData.lotteryVideo = 0;
                break;
            case 1:
                this._baseData.lotteryVideo += 1;
                break;
        }
        this._baseData.saveStorage();
    }

    // 拍子合成数据
    getColumn() {
        if (this._baseData.column == null) {
            return false;
        }

        if (JSON.stringify(this._baseData.column) == '{}') {
            return false;
        }

        return this._baseData.column;
    }
    setColumn(data) {
        this._baseData.column = data;
        // this._baseData.saveStorage();
    }

    // 购买蚊拍的次数
    getBuyBatCount() {
        return this._baseData.buyBatCount;
    }
    setBuyBatCount() {
        this._baseData.buyBatCount += 1;
        this._baseData.saveStorage();

    }

    // 签到的次数
    getSignCount() {
        return {
            status: this._baseData.isSign,
            count: this._baseData.signCount,
        };
    }
    setSignCount(number) {
        this._baseData.signCount = number;
        this._baseData.saveStorage();
    }
    setIsSign(state) {
        this._baseData.isSign = state;
        this._baseData.saveStorage();
    }

    // 收益视频次数
    getProfitVideo() {
        return this._baseData.profitVideo;
    }
    setProfitVideo() {
        this._baseData.profitVideo += 1;
        this._baseData.saveStorage();
    }

    // 获取头像
    getHeadIconId() {
        return this._baseData.headIconId;
    }
    setHeadIconId(id) {
        this._baseData.headIconId = id;
        this._baseData.saveStorage();
    }

    // 当局的消灭蚊子数量
    getEnemyCount() {
        return this._baseData.enemyCount;
    }
    setEnemyCount(number: number) {
        if (number == 0) {
            this._baseData.enemyCount = 0;
        } else {
            this._baseData.enemyCount += number;
        }
    }

    // 每种拍子购买的次数
    getBatCountList() {
        return this._baseData.batCountList;
    }
    setBatCountList(data) {
        this._baseData.batCountList = data;
    }

    getBatPos() {
        return this._baseData.batPos;
    }
    setBatPos(data) {
        this._baseData.batPos = data;
    }

    getObstacleStatus() {
        return this._baseData.obstacleStatus;
    }
    setObstacleStatus(values) {
        this._baseData.obstacleStatus = values;
    }

    // 自动合成拍子的状态
    // Constants.GameControl.setMixBatStatus(true);
    getMixBatStatus() {
        return this._baseData.mixBatStatus;
    }
    setMixBatStatus(state: boolean) {
        this._baseData.mixBatStatus = state;
    }

    // 获取录屏分享次数
    getShareVideoCount() {
        return this._baseData.shareVideoCount;
    }
    setShareVideoCount(num: number) {
        if (num == 0) {
            this._baseData.shareVideoCount = 0;
        } else {
            this._baseData.shareVideoCount == 5 ? this._baseData.shareVideoCount = 5 : this._baseData.shareVideoCount += 1;
        }
    }

    // 获取赛道长度
    getRoadLength() {
        return this._baseData.roadLength;
    }
    setRoadLength(length) {
        this._baseData.roadLength = length;
    }

    // 小程序引导弹窗
    getReminderStatus() {
        return this._baseData.reminderStatus;
    }
    setReminderStatus(state) {
        this._baseData.reminderStatus = state;
    }

    // 新手引导
    getIsTips() {
        return this._baseData.isTips;
    }
    setIsTips() {
        // 通过了新手引导
        this._baseData.isTips = 2;
    }

    // 用户当前状态
    getIsHome() {
        return this._baseData.isHome;
    }
    setIsHome(id) {
        this._baseData.isHome = id;
    }

    // 离拍子死亡最近的复活点
    getReborn() {
        return this._baseData.reborm;
    }
    setReborn(pos) {
        this._baseData.reborm = pos;
    }

    // 读取已加载的地图信息
    getLoadMapID() {
        return this._baseData.loadMapID;
    }
    setLoadMapID(id) {
        this._baseData.loadMapID = id;
    }

    // 获取应用标识
    getAppName() {
        return this._baseData.appName;
    }
    setAppName(str) {
        this._baseData.appName = str;
    }

    // 游戏通关状态
    getGamePassState() {
        return this._baseData.gamePassState;
    }
    setGamePassState(state) {
        this._baseData.gamePassState = state;
    }

    // 磁铁技能使用状态
    getMagnetState() {
        return this._baseData.magnetState;
    }
    setMagnetState(state) {
        this._baseData.magnetState = state;
    }

    // 在天空之城上
    getFlyState() {
        return this._baseData.flyState;
    }
    setFlyState(state) {
        this._baseData.flyState = state;
    }

    // 
    getUnlockChipBatId() {
        return this._baseData.unlockChipBatId;
    }
    setUnlockChipBatId(id) {
        this._baseData.unlockChipBatId = id;
    }

    // =============================新项目（画X）===========================
    // 获取配置表版本号
    getConfigVersion() {
        // return this._baseData.configVersion;
        return IniData.CONFIGVERSION;
    }

    getVersion() {
        // return this._baseData.version;
        return IniData.GAMEVERSION;
    }

    getArmsPosList() {
        return this._baseData.armsPosList;
    }
    setArmsPosList(data) {
        this._baseData.armsPosList = [];
        this._baseData.armsPosList = data;
    }

    // 主角的位置
    getPlayerPos() {
        return this._baseData.playerPos;
    }
    setPlayerPos(pos) {
        this._baseData.playerPos = pos;
    }

    // ai头像id
    getAIIconList() {
        return this._baseData.AIIconList;
    }
    setAIIconList(id, type?) {
        if (type) {
            this._baseData.AIIconList = [];
        } else {
            this._baseData.AIIconList.push(id);
        }
    }

    // 主角当前使用的皮肤
    getPlayerSkill() {
        return this._baseData.playerSkill;
    }
    setPlayerSkill(id: number) {
        this._baseData.playerSkill = id;
        this._baseData.saveStorage();
    }

    // // 本局中的排名
    // getRanking() {
    //     return this._baseData.ranking;
    // }
    // setRanking(number) {
    //     this._baseData.ranking = number;
    // }

    // 本局中主角击败的AI数量
    getBeatAICount() {
        return this._baseData.beatAICount;
    }
    setBeatAICount(number) {
        this._baseData.beatAICount = number;
    }

    // 武器长度
    getArmsLength() {
        return this._baseData.armsLength;
    }
    setArmsLength(length) {
        this._baseData.armsLength = length;
        this._baseData.saveStorage();
    }

    // 试用皮肤
    getTrySkill() {
        return this._baseData.trySkill;
    }
    setTrySkill(id) {
        this._baseData.trySkill = id;
        this._baseData.saveStorage();
    }

    // 用户当前场景（1：大厅，2：游戏中）
    getSceenState() {
        return this._baseData.sceenState;
    }
    setSceenState(id) {
        this._baseData.sceenState = id;
    }

    // 统计各个AI和主角击杀数量(id:100是主角)
    getattackList() {
        let a = this.getCount(this._baseData.attackList, 5, 4);
        for (let index = 0; index < a.length; index++) {
            if (a[index]['el'] === '100') {
                return index + 1;
            }
        }
        return 0;
    }
    getCount(arr, rank, ranktype) {
        var obj = {}, k, arr1 = [];
        for (var i = 0, len = arr.length; i < len; i++) {
            k = arr[i];
            if (obj[k])
                obj[k]++;
            else
                obj[k] = 1;
        }
        for (var o in obj) {
            arr1.push({ el: o, count: obj[o] });
        }
        arr1.sort(function (n1, n2) {
            return n2.count - n1.count
        });
        if (ranktype === 1) {
            arr1 = arr1.reverse();
        }
        var rank1 = rank || arr1.length;
        return arr1.slice(0, rank1);
    }
    setattackList(id, state?) {
        if (state) {
            this._baseData.attackList = [];
        } else {
            this._baseData.attackList.push(id);
        }
    }

    // 游戏的状态
    getGameState() {
        return this._baseData.gameState;
    }
    setGameState(state) {
        this._baseData.gameState = state;
    }

    // 已有皮肤
    getSkillList() {
        return this._baseData.skillList;
    }
    setSkillList(id: number) {
        if (this._baseData.skillList.indexOf(id) === -1) {
            this._baseData.skillList.push(id);
            this._baseData.saveStorage();
        }
    }

    // 主角的形体大小
    getPlayerSize() {
        return this._baseData.playerSize;
    }
    setPlayerSize(size) {
        this._baseData.playerSize += size;
        this._baseData.saveStorage();
    }

    // 主角击败一个AI获取到的金币数量
    getPlayerGold() {
        return this._baseData.playerGold;
    }
    setPlayerGold(gold) {
        this._baseData.playerGold += gold;
        this._baseData.saveStorage();
    }

    // 主角击败一个AI获取到的金币数量
    getPlayerQuick() {
        return this._baseData.playerQuick;
    }
    setPlayerQuick(quick) {
        this._baseData.playerQuick += quick;
        this._baseData.saveStorage();
    }

    // 主角的攻击力
    getPlayerAttack() {
        return this._baseData.playerAttack;
    }
    setPlayerAttack(attack) {
        this._baseData.playerAttack += attack;
        this._baseData.saveStorage();
    }

    // 主角的速度
    getPlayerSpeed() {
        return this._baseData.playerSpeed;
    }
    setPlayerSpeed(speed) {
        this._baseData.playerSpeed += speed;
        this._baseData.saveStorage();
    }

    // 画笔颜色(等级)
    getPenColorId() {
        return this._baseData.penColorId;
    }
    setPenColorId(id) {
        this._baseData.penColorId = id;
        this.setPenList(id);
    }

    // 画笔列表
    getPenList() {
        return this._baseData.penList;
    }
    setPenList(id) {
        if (this._baseData.penList.indexOf(id) === -1) {
            this._baseData.penList.push(id);
            this._baseData.saveStorage();
        }
    }

    // 玩家当前模型
    getPlayerModel() {
        return this._baseData.playerModel;
    }
    setPlayerModel(id) {
        this._baseData.playerModel = id;
        this._baseData.saveStorage();
    }

    // 玩家试用模型
    getPlayerTryModel() {
        return this._baseData.playerTryModel;
    }
    setPlayerTryModel(id) {
        this._baseData.playerTryModel = id;
        this._baseData.saveStorage();
    }

    // 试用状态
    getTrySkillState() {
        return this._baseData.trySkillState;
    }
    setTrySkillState(state) {
        this._baseData.trySkillState = state;
    }

    getCocosState() {
        // return this._baseData.cocosState;
        return IniData.COCOSASTATE;
    }
    getaldState() {
        // return this._baseData.aldState;
        return IniData.ALDASTATE;
    }
    gettoutiaoState() {
        // return this._baseData.toutiaoState;
        return IniData.TTASTATE;
    }

    // 彩蛋皮肤状态: 0：未解锁，1：使用中，2：使用
    getEggsList() {
        return this._baseData.eggsList;
    }
    setEggsList(index, value) {
        this._baseData.eggsList[index] = value;
        this._baseData.saveStorage();
    }

    // 未解锁的皮肤id
    getLockedSkillId() {
        return this._baseData.lockedSkillId;
    }
    setLockedSkillId(id: number) {
        this._baseData.lockedSkillId = id;
    }

    // 分享视频获取到的皮肤
    getVideoTrySkill() {
        return this._baseData.videoTrySkill;
    }
    setVideoTrySkill(id: number) {
        this._baseData.videoTrySkill = 0;
    }

    // 网络接口
    getHttpURLArr() {
        return [IniData.HTTPURL, IniData.PLATFORMTAG];
    }

    // 运行的平台
    getPlatform() {
        return IniData.PLATFORMCODE;
    }


}